# coding=utf-8
from django.contrib import admin

from core.wchat.models import WxMenu, WxMenuChild, WxUserInfo


class WxMenuChildInline(admin.StackedInline):
    model = WxMenuChild
    # max_num = 20
    extra = 0  # 用于添加外键关系模型的空行
    # verbose_name = '类别属性'  # 外键关系模型列表最下面的添加另外一个***,所用的名字
    # show_change_link = True  # 显示修改连接,这个很有用啊!!!!
    can_delete = True  # 是否显示删除框
    # exclude = ['create_sub_button_key_option']


class WxMenuAdmin(admin.ModelAdmin):
    """
    外键在同一页面
    """
    inlines = [WxMenuChildInline]


class WxUserInfoAdmin(admin.ModelAdmin):
    list_display = ("id", "nick_name")
    search_fields = ("nick_name",)


admin.site.register(WxMenu, WxMenuAdmin)  # 在admin中注册
admin.site.register(WxMenuChild)
admin.site.register(WxUserInfo, WxUserInfoAdmin)
